package com.booksystem.campuslibrarymanagementsystem.utils;

import com.booksystem.campuslibrarymanagementsystem.commen.request.adminrequest.AccountManagement.Auditlist;
import com.booksystem.campuslibrarymanagementsystem.commen.result.Result;
import com.booksystem.campuslibrarymanagementsystem.commen.result.Verifys;
import com.booksystem.campuslibrarymanagementsystem.entity.AccountTable;
import com.booksystem.campuslibrarymanagementsystem.entity.UserTable;
import com.booksystem.campuslibrarymanagementsystem.service.AccountTableService;
import com.booksystem.campuslibrarymanagementsystem.service.UserTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
public class AuditUtil {

    public static Verifys verifyUtil(String token,String idt, AccountTableService accountTableService) {
        Verifys v = new Verifys();
        Map<String, Object> parsed = JwtUtil.tokenPre(token);
        if (parsed != null) {
            Object identity = parsed.get("identity");
            Object account = parsed.get("account");
            if (idt.equals(identity)) {
                String acout = (String) account;
                AccountTable accountTable = accountTableService.queryByAccount(acout);
                if (accountTable != null) {
                    v.setMsg("成功");
                    v.setAccountTable(accountTable);
                    return v;
                } else {
                    v.setMsg("该学号不存在");
                    v.setAccountTable(null);
                    return v;
                }
            } else {
                v.setMsg("身份权限不足");
                v.setAccountTable(null);
                return v;
            }
        } else {
            v.setMsg("请输入正确token值");
            v.setAccountTable(null);
            return v;
        }
    }
}

